//=============================================================================
// Modified MP7 MedicGun Inventory class
//=============================================================================
class M7A3CAssaultRifle extends KFWeapon;

#exec OBJ LOAD FILE="..\Textures\KFWeaponPackTex.utx"
var         int         HealAmmoCharge2;
var() Material ScopeGreen;
var() Material ScopeRed;
var() ScriptedTexture MyScriptedTexture;
var() Shader AmmoCounter;
var string MyMessage;
var int MyHealth;
var   Font MyFont;
var   Font MyFont2;
var   Font SmallMyFont;
var  color MyFontColor;
var  color MyFontColor2;
var int OldValue;

replication
{
	// Things the server should send to the client.
	reliable if( Role==ROLE_Authority )
		HealAmmoCharge2;

 	reliable if( Role == ROLE_Authority )
		ClientSuccessfulHeal2;
}

 replication
{
	reliable if(Role < ROLE_Authority)
		ServerChangeFireMode;
}

// Use alt fire to switch fire modes
simulated function AltFire(float F)
{
    if(ReadyToFire(0))
    {
        DoToggle();
    }
}

// Toggle semi/auto fire
simulated function DoToggle ()
{
	local PlayerController Player;

	Player = Level.GetLocalPlayerController();
	if ( Player!=None )
	{
		//PlayOwnedSound(sound'Inf_Weapons_Foley.stg44_firemodeswitch01',SLOT_None,2.0,,,,false);
		FireMode[0].bWaitForRelease = !FireMode[0].bWaitForRelease;
		if ( FireMode[0].bWaitForRelease )
			Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',0);
		else Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',1);
	}
	Super.DoToggle();

	ServerChangeFireMode(FireMode[0].bWaitForRelease);
}

// Set the new fire mode on the server
function ServerChangeFireMode(bool bNewWaitForRelease)
{
    FireMode[0].bWaitForRelease = bNewWaitForRelease;
}

function bool RecommendRangedAttack()
{
	return true;
}

//TODO: LONG ranged?
function bool RecommendLongRangedAttack()
{
	return true;
}

function float SuggestAttackStyle()
{
	return -1.0;
}

exec function SwitchModes()
{
	DoToggle();
}

function float GetAIRating()
{
	local Bot B;

	B = Bot(Instigator.Controller);
	if ( (B == None) || (B.Enemy == None) )
		return AIRating;

	return AIRating;
}

function byte BestMode()
{
	return 0;
}



simulated final function SetTextColor( byte R, byte G, byte B )
{
	MyFontColor.R = R;
	MyFontColor.G = G;
	MyFontColor.B = B;
	MyFontColor.A = 255;


}

simulated final function SetTextColor2( byte R, byte G, byte B )
{
	MyFontColor2.R = R;
	MyFontColor2.G = G;
	MyFontColor2.B = B;
	MyFontColor2.A = 255;

 }

simulated function RenderOverlays( Canvas Canvas )
{

    local Pawn P;

   if( P.Health >=50 )
    {

     MyHealth = P.Health;
     SetTextColor2(76,148,177);
     ++MyScriptedTexture.Revision;
    }
    else
    {
    MyHealth = P.Health;
    SetTextColor2(218,18,18);
     ++MyScriptedTexture.Revision;
    }
	if( AmmoAmount(0) <= 0 )
	{
		if( OldValue!=-5 )
		{
			OldValue = -5;
			Skins[5] = ScopeRed;
			MyFont = SmallMyFont;
			SetTextColor(218,18,18);
			MyMessage = "Empty";
			++MyScriptedTexture.Revision;
		}
	}
	else if( bIsReloading )
	{
		if( OldValue!=-4 )
		{
			OldValue = -4;
			MyFont = SmallMyFont;
			SetTextColor(32,187,112);
			MyMessage = "REL";
			++MyScriptedTexture.Revision;
		}
	}
	else if( OldValue!=(MagAmmoRemaining+1) )
	{
		OldValue = MagAmmoRemaining+1;
		Skins[5] = ScopeGreen;
		MyFont = Default.MyFont;

		if ((MagAmmoRemaining ) <= (MagCapacity/2))
			SetTextColor(32,187,112);
		if ((MagAmmoRemaining ) <= (MagCapacity/3))
		{
			SetTextColor(218,18,18);
			Skins[5] = ScopeRed;
		}
		if ((MagAmmoRemaining ) >= (MagCapacity/2))
			SetTextColor(76,148,177);
		MyMessage = String(MagAmmoRemaining);

		++MyScriptedTexture.Revision;
	}

	MyScriptedTexture.Client = Self;
	//Skins[5] = AmmoCounter;
	Super.RenderOverlays(Canvas);
	MyScriptedTexture.Client = None;
	//Skins[5] = None;
}
simulated function RenderTexture( ScriptedTexture Tex )
{
	local int w, h;

	// Ammo
	Tex.TextSize( MyMessage, MyFont, w, h );
	Tex.DrawText( ( Tex.USize / 2 ) - ( w / 2 ), ( Tex.VSize / 2 ) - ( h / 1.2 ),MyMessage, MyFont, MyFontColor );
	// Health
	Tex.TextSize( MyHealth, MyFont2, w, h );
	Tex.DrawText( ( Tex.USize / 2 ) - ( w / 2 ), ( Tex.VSize / 2 ) - 8 ,MyHealth, MyFont2, MyFontColor2 );
}

defaultproperties
{
     ScopeGreen=Shader'KFWeaponPackTex.M7A3.Scope_Finall'
     scopered=Shader'KFWeaponPackTex.M7A3.ScopeRed_Shader'
     MyScriptedTexture=ScriptedTexture'KFWeaponPackTex.M7A3_Ammo_Script.AmmoNumber'
     MyFont=Font'IJCFonts.DigitalBig'
     MyFont2=Font'IJCFonts.DigitalBig'
     SmallMyFont=Font'IJCFonts.DigitalMed'
     MyFontColor=(B=177,G=148,R=76,A=255)
     MyFontColor2=(B=177,G=148,R=76,A=255)
     MagCapacity=37
     ReloadRate=3.066000
     ReloadAnim="Reload"
     ReloadAnimRate=1.000000
     WeaponReloadAnim="Reload"
     HudImage=Texture'KFWeaponPackTex.Icon.M7A3_idle'
     SelectedHudImage=Texture'KFWeaponPackTex.Icon.M7A3_inuse'
     Weight=4.000000
     bHasAimingMode=True
     IdleAimAnim="Idle_Iron"
     StandardDisplayFOV=55.000000
     bModeZeroCanDryFire=True
     SleeveNum=0
     TraderInfoTexture=Texture'KFWeaponPackTex.Icon.M7A3_Trader'
     PlayerIronSightFOV=65.000000
     ZoomedDisplayFOV=45.000000
     FireModeClass(0)=Class'UnitedMut_v54.M7A3CFire'
     FireModeClass(1)=Class'UnitedMut_v54.M7A3CAltFire'
     PutDownAnim="PutDown"
     SelectSound=Sound'KF_MP7Snd.MP7_Select'
     SelectForce="SwitchToAssaultRifle"
     AIRating=0.550000
     CurrentRating=0.550000
     bShowChargingBar=True
     Description="An advanced prototype assault rifle. Modified to fire healing darts."
     EffectOffset=(X=100.000000,Y=25.000000,Z=-10.000000)
     DisplayFOV=55.000000
     Priority=11
     InventoryGroup=4
     GroupOffset=8
     PickupClass=Class'UnitedMut_v54.M7A3CPickup'
     PlayerViewOffset=(X=9.500000,Y=9.000000,Z=-1.200000)
     BobDamping=5.500000
     AttachmentClass=Class'UnitedMut_v54.M7A3CAttachment'
     IconCoords=(X1=245,Y1=39,X2=329,Y2=79)
     ItemName="M7A3C AssaultRifle"
     Mesh=SkeletalMesh'KFWeaponPackAnims.M7A3'
     Skins(3)=Texture'KFWeaponPackTex.M7A3.NoMat'
     TransientSoundVolume=1.250000
}
